<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('货品绑定库位组')" />


<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/font/iconfont.css}" media="all"/>
<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/layui/css/layui.css}" media="all"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" media="all"/>
<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <input type="hidden" th:value="${hpid}" id="hpid" name="id">
                </form>

                <!--列表-->
                <section class="panel panel-padding layui-card-body" >
                    <div class="pro">
                        <table id="table"  class="table text-nowrap" style="word-break:break-all; word-wrap:break-word;"></table>
                    </div>
                </section>
                <div class="group-button" style="float:right;margin-bottom: 10px">
                    <a class="layui-btn layui-btn-sm layui-btn-normal save">
                        <i class="layui-icon">&#x1005;</i> 保存
                    </a>
                    <a class="layui-btn layui-btn-sm layui-btn-normal closes">
                        <i class="layui-icon">&#x1005;</i> 取消
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" th:src="@{/plugin/layui/js/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layui/js/version.js}"></script>
<script th:src="@{/plugin/layui/js/common.js}"></script>
<div th:include="public/public_js::public_js"></div>

<script>
    //	回车查询
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            //执行的方法
            $('#search_button').click();
        }
    };
    layui.use(['list','layer','zzpUtils','jquery','laydate'],function () {
        window.operateEvent = {
            //预检
            "click .detail": function (e, value, row, index) {//增加地址

                console.info("增加地址");
                detail(row, index);
            },
        }
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            layer = layui.layer,
            laydate = layui.laydate;

        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: false,
            url: '/wmsgoods/seachLibrarypositiongroup',
            method:'post',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'mc',
                title: '库位组名称',
                align : 'center'
            }, {
                field: 'ms',
                title: '库位组描述',
                align : 'center'
            }, {
                field: 'kws',
                title: '库位数',
                align : 'center'
            }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (row, index) {
                return "这里就没有确定过11";
            },

        });

        //保存
        $(".save").on('click',function () {
            var rows = $table.bootstrapTable('getSelections');
            var ids=[];
            var obj={};
            if(rows.length == 0){
                layer.msg("请至少选择一条");
            }else{
                for(var i=0;i<rows.length;i++){
                    ids.push(rows[i].id)
                }
                obj={"hpid":$("#hpid").val(),"ids":ids};
                console.info(rows);
                zzpUtils.confirm("是否确定保存", function (index) {
                    zzpUtils.action({
                        url: "/wmsgoods/addLibrarypositiongroupBindingGoods",
                        data: JSON.stringify(obj),
                        success: function (data) {
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                                console.info(data);
                                top.layer.msg(data.title + "," + data.message);
                                //刷新父页面
                                parent.location.reload();
                            }, 500);
                        }, error: function (xhr, textStatus) {
                            console.log(textStatus);
                            console.log(xhr)
                        }
                    })
                })
            }
        })

        //关闭
        $(".closes").on('click',function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        })

    })

</script>
</html>